// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <ostream>
#include <stdint.h>

namespace kmsql {
    enum class DataType {
        UNKNOWN,
        BIGINT,
        BOOLEAN,
        CHAR,
        DATE,
        DATETIME,
        DECIMAL,
        DOUBLE,
        FLOAT,
        INT,
        LONG,
        REAL,
        SMALLINT,
        TEXT,
        TIME,
        VARCHAR,
    };

    // Represents the type of a column, e.g., FLOAT or VARCHAR(10)
    struct ColumnType {
        ColumnType() = default;

        ColumnType(DataType data_type, int64_t length = 0, int64_t precision = 0, int64_t scale = 0);

        DataType data_type;
        int64_t length; // Used for, e.g., VARCHAR(10)
        int64_t precision; // Used for, e.g., DECIMAL (6, 4) or TIME (5)
        int64_t scale; // Used for DECIMAL (6, 4)
    };

    bool operator==(const ColumnType &lhs, const ColumnType &rhs);

    bool operator!=(const ColumnType &lhs, const ColumnType &rhs);

    std::ostream &operator<<(std::ostream &, const ColumnType &);
} // namespace kmsql
